#include "loggedusers.h"

//Static variables
QMutex LoggedUsers::mutex;
QHash<int, QThread*> LoggedUsers::usersThreads;

LoggedUsers::LoggedUsers()
{
}

void LoggedUsers::addUserThread(int userId, QThread *thread)
{
    mutex.lock();
    usersThreads[userId] = thread;
    mutex.unlock();
}

void LoggedUsers::delUserThread(int userId) {
    mutex.lock();
    usersThreads.remove(userId);
    mutex.unlock();
}

QThread * LoggedUsers::getUserThread(int userId) {
    QThread * tempThreadPointer;
    mutex.lock();
    tempThreadPointer = usersThreads[userId];
    mutex.unlock();
    return tempThreadPointer;
}
